<template>
    <div class = "articleshows">
         <div style='height:500px;width:700px;'>
            <div class='quill-editor'>
                <div class="ql-container">
                	<!-- 利用v-html标签做到原样展示 -->
                    <div class='ql-editor' v-html="quillHtml">
                    </div> 
                </div>
            </div>
        </div>
    </div>
</template>
<script>
var toolbarOptions = [
  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
  ['blockquote', 'code-block'],
  [{ 'header': 1 }, { 'header': 2 }],               // custom button values
  [{ 'list': 'ordered'}, { 'list': 'bullet' }],
  [{ 'script': 'sub'}, { 'script': 'super' }],      // superscript/subscript
  [{ 'indent': '-1'}, { 'indent': '+1' }],          // outdent/indent
  [{ 'direction': 'rtl' }],                         // text direction
  [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
  [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
  [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme
  [{ 'font': [] }],
  [{ 'align': [] }],
  ['clean']                                         // remove formatting button
];
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
export default {
    props: {
        quillHtmlStr: {
            type: String
        }
    },
    data(){
        return{
            quillHtml: ""
        }
    },
    created(){
        //这里的created钩子只会执行一次,所以做不到传递异步数据的效果
        // this.quillHtml = this.quillHtmlStr
        console.log(this.quillHtml,this.quillHtmlStr)
    },
    watch: {
      //利用watch来实现传递异步数据
      "quillHtmlStr": function(newVal,oldVal){
          this.quillHtml = newVal
          console.log(this.quillHtml)
      }
    },
}
</script>
<style scoped>

</style>
